package com.health.test;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Calendar;
import java.util.Date;

import javax.swing.JFrame;
import javax.swing.Timer;

public class MyFrame extends JFrame  {
	
	private Date lastTime; 
	
	public Date getLastTime() {
		return lastTime;
	}

	public void setLastTime(Date lastTime) {
		this.lastTime = lastTime;
	}

	public void createAndShowUI(){
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		Container contentPane = getContentPane();
		
		addMouseListener(new MouseListener(){

			public void mouseClicked(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}

			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				lastTime = Calendar.getInstance().getTime();
			}

			public void mouseExited(MouseEvent e) {
				// TODO Auto-generated method stub
				lastTime = null;
			}

			public void mousePressed(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}

			public void mouseReleased(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
		});
		
		setPreferredSize(new Dimension(300,200));
		pack();
		setLocationRelativeTo(null);
		setVisible(true);
		
	}
	
	public static void main(String[] args) {
		
	/*	final MyFrame frame = new MyFrame();
		frame.createAndShowUI();
		
		ActionListener listener = new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				if(frame.getLastTime()!=null){
					Date last = frame.getLastTime();
					Date now = Calendar.getInstance().getTime();
					if((now.getTime()-last.getTime())>20000){
						System.out.println("悬浮了3秒");
					}
				}
			}
		};
		int delay = 1000;
		Timer timer = new Timer(delay,listener);
		timer.start();*/
		
		
		 DragWindow   test   =   new   DragWindow(); 
         test.setPreferredSize(new Dimension(3000, 30));
         //test.pack();window 没放东西这个先不要
         test.setVisible(true);
         test.setAlwaysOnTop(true);
		
	}
	
}


